package com.j3a.journal.model;

// Generated 21 oct. 2014 14:53:50 by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "user", catalog = "journal")
public class User implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Integer userId;
    private UserRole userRole;
    private String userPseudo;
    private String userPassword;
    private Boolean userEnabled;
    private Set<Journaliste> journalistes = new HashSet<Journaliste>(0);

    public User() {
    }

    public User(UserRole userRole) {
	this.userRole = userRole;
    }

    public User(UserRole userRole, String userPseudo, String userPassword,
	    Boolean userEnabled, Set<Journaliste> journalistes) {
	this.userRole = userRole;
	this.userPseudo = userPseudo;
	this.userPassword = userPassword;
	this.userEnabled = userEnabled;
	this.journalistes = journalistes;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "USER_ID", unique = true, nullable = false)
    public Integer getUserId() {
	return this.userId;
    }

    public void setUserId(Integer userId) {
	this.userId = userId;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "USER_ROLE_ID", nullable = false)
    public UserRole getUserRole() {
	return this.userRole;
    }

    public void setUserRole(UserRole userRole) {
	this.userRole = userRole;
    }

    @Column(name = "USER_PSEUDO", length = 50)
    public String getUserPseudo() {
	return this.userPseudo;
    }

    public void setUserPseudo(String userPseudo) {
	this.userPseudo = userPseudo;
    }

    @Column(name = "USER_PASSWORD", length = 100)
    public String getUserPassword() {
	return this.userPassword;
    }

    public void setUserPassword(String userPassword) {
	this.userPassword = userPassword;
    }

    @Column(name = "USER_ENABLED")
    public Boolean getUserEnabled() {
	return this.userEnabled;
    }

    public void setUserEnabled(Boolean userEnabled) {
	this.userEnabled = userEnabled;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
    public Set<Journaliste> getJournalistes() {
	return this.journalistes;
    }

    public void setJournalistes(Set<Journaliste> journalistes) {
	this.journalistes = journalistes;
    }

}
